package com.example.demo.entry;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.ldap.core.DistinguishedName;
import org.springframework.ldap.odm.annotations.Entry;
import org.springframework.ldap.odm.annotations.Id;

import javax.naming.Name;

/**
 * @author: YZD
 * @Date: 2020-04-29 21:44
 */
@Entry(objectClasses = {"organizationalUnit"}, base = "dc=huanqiu,dc=com")
public class Organization {
    @Id
    @JsonIgnore
    private Name dn;
    private String ou; //必填属性
    private String description;
    private String physicalDeliveryOfficeName;//office
    private String telephoneNumber;
    private String facsimileTelephoneNumber;//fax
    private String street;
    private String postOfficeBox;
    private String postalAddress;
    private String l;//city
    private String st;
    private String postalCode;
    private String businessCategory;

    public void setOu(String ou) {
        if (this.dn == null) {
            DistinguishedName newContactDN = new DistinguishedName();
            // 添加cn，即使得该条记录的dn为"cn=cn,根目录",例如"cn=abc,dc=testdc,dc=com"
            DistinguishedName name1 = new DistinguishedName("ou=" + ou);
            name1.append(newContactDN);
            this.dn = name1;
        }
        String[] arr = ou.split(",");
        this.ou = arr[0];
    }

    public Name getDn() {
        return dn;
    }

    public void setDn(Name dn) {
        this.dn = dn;
    }

    public String getOu() {
        return ou;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getPhysicalDeliveryOfficeName() {
        return physicalDeliveryOfficeName;
    }

    public void setPhysicalDeliveryOfficeName(String physicalDeliveryOfficeName) {
        this.physicalDeliveryOfficeName = physicalDeliveryOfficeName;
    }

    public String getTelephoneNumber() {
        return telephoneNumber;
    }

    public void setTelephoneNumber(String telephoneNumber) {
        this.telephoneNumber = telephoneNumber;
    }

    public String getFacsimileTelephoneNumber() {
        return facsimileTelephoneNumber;
    }

    public void setFacsimileTelephoneNumber(String facsimileTelephoneNumber) {
        this.facsimileTelephoneNumber = facsimileTelephoneNumber;
    }

    public String getStreet() {
        return street;
    }

    public void setStreet(String street) {
        this.street = street;
    }

    public String getPostOfficeBox() {
        return postOfficeBox;
    }

    public void setPostOfficeBox(String postOfficeBox) {
        this.postOfficeBox = postOfficeBox;
    }

    public String getPostalAddress() {
        return postalAddress;
    }

    public void setPostalAddress(String postalAddress) {
        this.postalAddress = postalAddress;
    }

    public String getL() {
        return l;
    }

    public void setL(String l) {
        this.l = l;
    }

    public String getSt() {
        return st;
    }

    public void setSt(String st) {
        this.st = st;
    }

    public String getPostalCode() {
        return postalCode;
    }

    public void setPostalCode(String postalCode) {
        this.postalCode = postalCode;
    }

    public String getBusinessCategory() {
        return businessCategory;
    }

    public void setBusinessCategory(String businessCategory) {
        this.businessCategory = businessCategory;
    }
}
